<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
    if(empty($id)){
        
       jumpajax('300','没有找到回复信息!','');  
    }
    
	unset($_POST['id']);
	unset($_POST['sub']);
	$data=array('subject'=>$_POST['subject'],"content"=>trim($_POST["content"]),"send_to_id"=>trim($_POST["send_to_id"]),
    "folder"=>"inbox",
    "replyid"=>$id,
    "message_time"=>time(),
    "from_uid"=>$_SESSION['EZ_Admin']['id'],    
    "send_from_id"=>$_SESSION['EZ_Admin']['name']
    );
    

    if(trim($_POST['subject'])==""){
        jumpajax('300','回复标题不能为空!','');
    }
    if(trim($_POST['content'])==""){
        jumpajax('300','回复内容不能为空!','');
    }
    $row=$ezhand->select('message','*','id='.$id);
    if(empty($row)){
        jumpajax('300','没有找到回复信息!','');  
    }

    $data["send_to_id"]=$row["send_from_id"];
    $data["to_uid"]=$row["from_uid"];
    $id=$ezhand->insert("message",$data);   
  
	jumpajax('200','留言发送成功','','closeCurrent');

}
else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
    
    if(empty($id)){
        jumpajax('300',"留言不存在！",'closeCurrent');
	}else{
	   
       $row=$ezhand->select('message','*','id='.$id);
	}
	
}
?>